package com.blog.utils;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

public class CommonUtil {

	public static String getBasePath(HttpServletRequest request){
		String path = request.getContextPath();
		String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
		return basePath;
	}
	
	/**
	 * 判断对象是否为空对象
	 * 
	 * @param obj
	 * @return
	 */
	public static boolean isEmpty(Object obj) {
		if (null == obj) {
			return true;
		}
		return false;
	}

	/**
	 * 判断集合是否为空
	 * 
	 * @param list
	 * @return
	 */
	public static boolean isEmpty(List<?> list) {
		if (null != list && list.size() > 0) {
			return false;
		}
		return true;
	}

	public static boolean isEmpty(Map<?, ?> map) {
		if (null != map && map.size() > 0) {
			return false;
		}
		return true;
	}

	public static boolean isEmpty(String str) {
		if (null != str && !"".equals(str)) {
			return false;
		}
		return true;
	}
	
	public static void main(String[] args) {
		Object obj = "";
		System.out.println(isEmpty(obj));
	}
}
